package com.yztc.demo.dao;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * Created by Administrator on 2017/7/21.
 */
public class UserProxy implements InvocationHandler {
    Object object;
    public Object newInstance(Object obj){
        this.object=obj;
        return Proxy.newProxyInstance(obj.getClass().getClassLoader(),
                obj.getClass().getInterfaces(),this);

    }
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("开始卑职");
        Object invoke = method.invoke(object, args);
        System.out.println("结束配置");
        return invoke;
    }
}
